﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WFASmartketing.UTIIIDADES
{
    public static class UTILIDADES
    {

        public static void soloDecimanes(System.Windows.Forms.KeyPressEventArgs e, TextBox textBox1)
        {
          if (textBox1.Text.Contains('.'))
           {
                      if(!char.IsDigit(e.KeyChar))
                      {
                               e.Handled = true;
                       }

                       if (e.KeyChar == '\b')
                       {
                                e.Handled = false;
                        }
           }
           else
           {
                          if(!char.IsDigit(e.KeyChar))
                          {
                                  e.Handled = true;
                           }

                           if(e.KeyChar=='.'|| e.KeyChar=='\b')
                          {
                                   e.Handled = false;
                          }
            }
        }
       public static void Mayuscula(System.Windows.Forms.KeyPressEventArgs e)
        {
            e.KeyChar = char.ToUpper(e.KeyChar);
        }
       public static void soloEnteros(System.Windows.Forms.KeyPressEventArgs e)
        {
             if (Char.IsDigit(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsSeparator(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }
    }
}
